home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / Time.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-16  |  4.7 KB  |  204 lines

  1. /* Copyright (C) 1986-2001 by Digital Mars. $Revision: 1.1.1.2 $ */
  2. #if __SC__ || __RCC__
  3. #pragma once
  4. #endif
  5.  
  6. #ifndef __TIME_H
  7. #define __TIME_H 1
  8.  
  9. #if __cplusplus
  10. extern "C" {
  11. #endif
  12.  
  13. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  14. #ifndef _CRTAPI1
  15. #define _CRTAPI1 __cdecl
  16. #endif
  17.  
  18. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  19. #ifndef _CRTAPI2
  20. #define _CRTAPI2 __cdecl
  21. #endif
  22.  
  23. /* Define CRTIMP */
  24. #ifndef _CRTIMP
  25. #if defined(_WIN32) && defined(_DLL)
  26. #define _CRTIMP  __declspec(dllimport)
  27. #else
  28. #define _CRTIMP
  29. #endif
  30. #endif
  31.  
  32. typedef unsigned size_t;
  33.  
  34. #ifndef __STDC__
  35. #if !defined(_WCHAR_T_DEFINED)
  36. typedef unsigned short wchar_t;
  37. #define _WCHAR_T_DEFINED 1
  38. #endif
  39. #endif
  40.  
  41. #define CLOCKS_PER_SEC ((clock_t)1000) /* (clock_t / CLOCKS_PER_SEC) == seconds */
  42.  
  43. #if !__STDC__
  44. #define CLK_TCK ((clock_t)1000) /* (clock_t / CLK_TCK) == seconds      */
  45. #endif
  46.  
  47. #ifndef NULL
  48. #ifdef __cplusplus
  49. #define NULL 0
  50. #else
  51. #define NULL ((void *)0)
  52. #endif
  53. #endif
  54.  
  55. typedef long clock_t;
  56. #ifndef __TIME_T_DEFINED
  57. typedef long time_t;
  58. #define __TIME_T_DEFINED
  59. #endif
  60.  
  61. #if __OS2__ && __INTSIZE == 4
  62. #define __CLIB __stdcall
  63. #else
  64. #define __CLIB __cdecl
  65. #endif
  66.  
  67. _CRTIMP extern int daylight;
  68. _CRTIMP extern long timezone;
  69. _CRTIMP extern long altzone;
  70. _CRTIMP extern char * const tzname[2];
  71.  
  72. #define _daylight daylight
  73. #define _timezone timezone
  74. #define _tzname tzname
  75.  
  76. #ifndef _STRUCTTM_DEFINED
  77. #define _STRUCTTM_DEFINED 1
  78. struct tm
  79. {      int     tm_sec,
  80.                tm_min,
  81.                tm_hour,
  82.                tm_mday,
  83.                tm_mon,
  84.                tm_year,
  85.                tm_wday,
  86.                tm_yday,
  87.                tm_isdst;
  88. };
  89. #endif
  90.  
  91.  
  92. #define _TIMEOFFSET     315558000
  93.  
  94. #if !__STDC__
  95. #define TIMEOFFSET  _TIMEOFFSET
  96. #endif
  97.  
  98. clock_t __CLIB clock(void);
  99. time_t __CLIB time(time_t *);
  100. time_t __CLIB mktime(struct tm *);
  101. char * __CLIB asctime(const struct tm *);
  102. char * __CLIB ctime(const time_t *);
  103. struct tm * __CLIB localtime(const time_t *);
  104. struct tm * __CLIB gmtime(const time_t *);
  105. size_t __CLIB strftime(char *,size_t,const char *,const struct tm *);
  106. char * __CLIB _strdate(char *dstring);
  107. char * __CLIB _strtime(char *timestr);
  108. double __CLIB difftime(time_t t1,time_t t2);
  109. void __CLIB _tzset(void);
  110.  
  111.  
  112. #if !__STDC__
  113. #if M_UNIX || M_XENIX
  114.  
  115. #if !defined(_POSIX_SOURCE)
  116. struct timeval {
  117.        long    tv_sec;
  118.        long    tv_usec;
  119. };
  120.  
  121. struct timezone {
  122.        int     tz_minuteswest;
  123.        int     tz_dsttime;
  124. };
  125.  
  126. #define        DST_NONE        0
  127. #define        DST_USA         1
  128. #define        DST_AUST        2
  129. #define        DST_WET         3
  130. #define        DST_MET         4
  131. #define        DST_EET         5
  132. #define        DST_CAN         6
  133. #define        DST_GB          7
  134. #define        DST_RUM         8
  135. #define        DST_TUR         9
  136. #define        DST_AUSTALT     10
  137.  
  138. #define        timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
  139. #define        timercmp(tvp, uvp, cmp) ((tvp)->tv_sec cmp (uvp)->tv_sec || \
  140.         (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
  141. #define        timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
  142.  
  143. #define        ITIMER_REAL     0
  144. #define        ITIMER_VIRTUAL  1
  145. #define        ITIMER_PROF     2
  146.  
  147. struct itimerval {
  148.        struct timeval  it_interval;
  149.        struct timeval  it_value;
  150. };
  151.  
  152. #if !defined(__STDC__)
  153. int __cdecl adjtime(struct timeval *, struct timeval *);
  154. int __cdecl getitimer(int, struct itimerval *);
  155. int __cdecl setitimer(int, struct itimerval *, struct itimerval *);
  156. #endif /* __STDC__ */
  157. #endif /* !defined(_POSIX_SOURCE) */
  158.  
  159. struct tms
  160. {      time_t  tms_utime;      /* user                 */
  161.        time_t  tms_stime;      /* system               */
  162.        time_t  tms_cutime;     /* user children        */
  163.        time_t  tms_cstime;     /* system children      */
  164. };
  165.  
  166. typedef struct
  167.         {
  168.         time_t  tv_sec;
  169.         long    tv_nsec;
  170.         } timestruc_t;
  171.  
  172. clock_t __CLIB times(struct tms *);
  173. unsigned int __CLIB sleep(unsigned int);
  174. long int __CLIB nap(long int mS);
  175. #define usleep(s) (void)nap((s)/1000)
  176. #define msleep(s) (void)nap(s)
  177.  
  178. #else /* M_UNIX || M_XENIX */
  179.  
  180. void __CLIB sleep(time_t);
  181. void __CLIB usleep(unsigned long);
  182. void __CLIB msleep(unsigned long);
  183. #endif /* M_UNIX || M_XENIX */
  184.  
  185. void __cdecl tzset(void);
  186.  
  187. #endif /* !__STDC__ */
  188.  
  189. #ifdef __NT__
  190. #ifndef __STDC__
  191. wchar_t * __cdecl _wasctime(const struct tm *);
  192. wchar_t * __cdecl _wctime(const time_t *);
  193. size_t __cdecl wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *);
  194. wchar_t * __cdecl _wstrdate(wchar_t *);
  195. wchar_t * __cdecl _wstrtime(wchar_t *);
  196. #endif
  197. #endif
  198.  
  199. #if __cplusplus
  200. }
  201. #endif
  202.  
  203. #endif
  204.